<template>
  <div class="meet-info-container">
    <div class="background-animation"></div>
    <div class="main-content-flex">
      <div class="logo-container">
        <img src="@/assets/images/newlog.png" alt="富创云会议" class="logo" />
        <span class="logo-text">富创云会议</span>
      </div>
      <div class="meet-content-wrapper">
        <div class="meet-content">
          <h1>现场会议信息</h1>
          <div class="meeting-info">
            <!-- 会议号已移除 -->
            <div class="info-item">
              <span class="label">会议主题：</span>
              <span class="value">{{ meetingInfo.subject || '加载中...' }}</span>
            </div>
            <div class="info-item">
              <span class="label">会议时间：</span>
              <span class="value">{{ formatTime(meetingInfo.startTime) || '加载中...' }} - {{ formatTime(meetingInfo.endTime, false) || '加载中...' }}</span>
            </div>
            <div class="info-item">
              <span class="label">会议类型：</span>
              <span class="value">{{ getMeetingType(meetingInfo.meetType) || '加载中...' }}</span>
            </div>
            <div class="info-item">
              <span class="label">会议地点：</span>
              <span class="value">{{ meetingInfo.meetType === 1 ? '线上会议' : (meetingInfo.location || '线下会议') }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { Message } from '@arco-design/web-vue'
import request from '@/utils/request'

interface MeetingInfo {
  conferenceId: string
  subject: string
  location: string | null
  startTime: string | null
  endTime: string | null
  meetType: number
  circleType: number
  mediaType: number
  huaweiUrl: string
  guestPassword: string
}

const route = useRoute()
const conferenceId = ref('')
const meetingInfo = ref<MeetingInfo>({
  conferenceId: '',
  subject: '',
  location: null,
  startTime: null,
  endTime: null,
  meetType: 1,
  circleType: 0,
  mediaType: 1,
  huaweiUrl: '',
  guestPassword: ''
})

const getMeetingInfo = async () => {
  try {
    const id = route.query.conferenceId as string
    if (!id) {
      Message.error('缺少会议ID')
      return
    }
    conferenceId.value = id
    const response = await request.get('/system/meet/joinMeet', {
      params: { conferenceId: id }
    })
    meetingInfo.value = response.data
  } catch (error) {
    Message.error('获取会议信息失败')
  }
}

const formatTime = (time: string | null, showDate = true) => {
  if (!time) return ''
  const [datePart, timePart] = time.split(' ')
  if (!datePart || !timePart) return time
  const [hours, minutes] = timePart.split(':').slice(0, 2)
  const isMobile = window.innerWidth <= 600
  if (!showDate) {
    return `${hours}:${minutes}`
  }
  if (isMobile) {
    const [, month, day] = datePart.split('-')
    return `${month}-${day} ${hours}:${minutes}`
  }
  return `${datePart} ${hours}:${minutes}`
}

const getMeetingType = (type: number) => {
  return type === 1 ? '线上会议' : '线下会议'
}

onMounted(() => {
  getMeetingInfo()
})
</script>

<style scoped>
.meet-info-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  background: #f6f8fa;
  position: relative;
  overflow: hidden;
}
.background-animation {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(-45deg, #1e3a8a, #3b82f6, #60a5fa, #93c5fd);
  background-size: 400% 400%;
  animation: gradient 15s ease infinite;
  z-index: 0;
}
@keyframes gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.main-content-flex {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  position: relative;
  z-index: 1;
}
.logo-container {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}
.logo {
  width: 32px;
  height: 32px;
}
.logo-text {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.meet-content-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.meet-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 3rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 800px;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
}
h1 {
  text-align: center;
  margin-bottom: 3rem;
  color: #1e3a8a;
  font-size: 32px;
  font-weight: 600;
}
.meeting-info {
  margin-bottom: 3rem;
  padding: 2rem;
  background-color: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.1);
}
.info-item {
  margin: 1rem 0;
  display: flex;
  align-items: center;
}
.label {
  color: #1e3a8a;
  width: 100px;
  flex-shrink: 0;
  font-weight: 500;
  font-size: 16px;
}
.value {
  color: #1e40af;
  flex: 1;
  font-size: 16px;
}
@media (max-width: 600px) {
  .meet-info-container {
    min-height: 100vh !important;
    height: 100vh !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  .main-content-flex {
    height: 100%;
    min-height: 0;
  }
  .meet-content-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 0 !important;
  }
  .meet-content {
    padding: 0.7rem 0.3rem 0.7rem 0.3rem !important;
    max-width: 98vw !important;
    min-width: 0 !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
    margin: 0 auto 6px auto !important;
    margin-top: 2vw !important;
  }
  .meeting-info {
    padding: 0.5rem 0.2rem 0.5rem 0.2rem !important;
    margin-bottom: 0.7rem !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    background: #fafdff !important;
    border: 1px solid #e3e8ee !important;
    box-shadow: 0 1px 2px rgba(30,58,138,0.02) !important;
  }
  .info-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    margin: 0.5rem 0 0.5rem 0 !important;
    padding-bottom: 0.4rem !important;
    border-bottom: 1px solid #f0f2f5 !important;
    width: 100% !important;
  }
  .info-item:last-child {
    border-bottom: none !important;
  }
  .label {
    font-size: 15px !important;
    width: auto !important;
    margin-bottom: 1px !important;
    color: #1e3a8a !important;
    font-weight: 600 !important;
  }
  .value {
    font-size: 15px !important;
    word-break: break-all !important;
    color: #1e40af !important;
    margin-bottom: 2px !important;
  }
}
</style>
